
/**
 * 
 * @author: xj.huang
 * @date: 2021/08/06 11:54:26
 */
export default class lunboxAni extends Laya.Script {
    /** @prop {name:boolType, tips:"是否为横屏滚动", type:Bool, default:true}*/
    public boolType: boolean = true;
    // 更多参数说明请访问: https://ldc2.layabox.com/doc/?nav=zh-as-2-4-0
    constructor() { super(); }
    public ban_list;
    private moveSeep=0;
    private spaceSeep=0;
    onAwake(){
        this.ban_list = this.owner
        Laya.timer.once(2000-2,this,this.onSetInfo)
        Laya.timer.loop(2000,this,this.uptimePlayItemAni)
    }
    onPlay(){

    }
    onSetInfo(){
        if( !this.ban_list) return;
        if(this.boolType){
            this.moveSeep = this.ban_list.cells[0].width
            this.spaceSeep = this.ban_list.spaceX
        }else{
            this.moveSeep = this.ban_list.cells[0].height
            this.spaceSeep = this.ban_list.spaceY

        }
        console.log("this.moveSeep",this.moveSeep,this.spaceSeep,this.boolType )
    }
    uptimePlayItemAni(){
         /**摆放单元格数据 */
        if (!this.ban_list&&this.ban_list.array.length <= 4) return;
        let now = this.ban_list.scrollBar.value + this.moveSeep + this.spaceSeep;
        Laya.Tween.to(this.ban_list.scrollBar, { value: now }, 100, null, Laya.Handler.create(this, function () {
            if (this.ban_list.scrollBar.value >= this.ban_list.scrollBar.max) this.ban_list.scrollBar.value = 0;
        }));
    }
}